package com.ls.herostory.util;

import org.redisson.Redisson;
import org.redisson.api.RMap;
import org.redisson.api.RScoredSortedSet;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;

/**
 * @author liangsu
 * @version v1.0
 * @Description
 * @Date 2020/10/14 16:42
 * @since
 */
public class RedisUtil {

    private static RedissonClient redisson = null;

    static {
        init();
    }

    public static void init(){
        Config config = new Config();
        SingleServerConfig singleServerConfig = config.useSingleServer();
        singleServerConfig.setAddress("redis://192.168.10.241:18040");
        singleServerConfig.setDatabase(1);
        redisson = Redisson.create(config);
    }

    public static RedissonClient getRedisson(){
        return redisson;
    }

    public static void main(String[] args) {
        init();
        RScoredSortedSet<Object> rankSet = redisson.getScoredSortedSet("rank_set");
        rankSet.add(2, "aa");
    }

}
